/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package remoteEntity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author viktor
 */
@Entity
@Table(name = "fileblob")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Fileblob.findByDataHash", query = "SELECT f FROM Fileblob f WHERE f.dataHash = :dataHash"),
    @NamedQuery(name = "Fileblob.findAll", query = "SELECT f FROM Fileblob f"),
    @NamedQuery(name = "Fileblob.findById", query = "SELECT f FROM Fileblob f WHERE f.id = :id")})
public class Fileblob implements Serializable {
    @Lob
    @Column(name = "dataFile")
    private byte[] dataFile;
    @Lob
    @Column(name = "dataHash")
    private String dataHash;
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "id")
    private Integer id;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fileblob")
    private Collection<Filedescription> filedescriptionCollection;

    public Fileblob() {
    }

    public Fileblob(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @XmlTransient
    public Collection<Filedescription> getFiledescriptionCollection() {
        return filedescriptionCollection;
    }

    public void setFiledescriptionCollection(Collection<Filedescription> filedescriptionCollection) {
        this.filedescriptionCollection = filedescriptionCollection;
    }
/*
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }*/

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Fileblob)) {
            return false;
        }
        Fileblob other = (Fileblob) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Fileblob[ id=" + id + " ] hash: +"+dataHash;
    }

    public byte[] getDataFile() {
        return dataFile;
    }

    public void setDataFile(byte[] dataFile) {
        this.dataFile = dataFile;
    }

    public String getDataHash() {
        return dataHash;
    }

    public void setDataHash(String dataHash) {
        this.dataHash = dataHash;
    }
    
}
